<template>
	<view class="contenter">
		<view v-for="(item,index) in dataList" :key="index">
			<view class="pd_card" >
				<view style="display: flex;text-align: center;line-height: 1.4;">
					<view style="flex: 4;text-align: left;">
						[{{item.brandName?item.brandName:'无'}}]{{item.name}}
					</view>
					<view style="flex: 1;">
						{{item.deliverNum}}
					</view>
					<view style="flex: 1;">
						{{item.storageNum}}
					</view>
				</view>
				<view style="display: flex;font-size: 26rpx;margin: 20rpx 0 0 0;">
					<view style="text-align: left;color: #898989;">
						{{item.skuName}}
					</view>
					<view style="margin: 0 10rpx;color: #e73107;background-color: #fdf7f4;">
						缺货高风险
					</view>
				</view>
			</view>
		</view>
		
	</view>
</template>

<script>
	export default {
		props: {
			// tab: {
			// 	type: [Object],
			// 	default: ''
			// },
			// parentId: {
			// 	type: String,
			// 	default: ''
			// },
			// bgColor: {
			// 	type: String,
			// 	default: 'blue'
			// },
			tabIndex: {
				type: Number,
				default: ''
			},
		},
		data() {
			return {
				cancellForm: {
					current: 1,
					size: 10,
				},
				totalPage: 1,
				loadMoreStatus: 'noMore', //加载更多
				dataList: [{
					brandName:'五湖',
					name:'一级大豆油20L',
					deliverNum:3,
					storageNum:3,
					skuName:'2.5kg/袋'
				},{
					brandName:'',
					name:'优质玉米面(中粗)',
					deliverNum:2,
					storageNum:2,
					skuName:'2.5kg/包(1袋)'
				}],
			}
		},
		created() {
			// this.initData();
		},
		methods: {
			initData() {
				// 首次激活时被调用
				this.cancellForm.current = 1;
				this.loadMoreStatus = 'more';

				this.getQueryList();
			},
			// 触底事件 onReachBottom 加载更多数据
			scrolltolowerFn() {
				if (this.loadMoreStatus != 'more') {
					return;
				};
				this.cancellForm.current++;
				this.getQueryList(true);
			},
			toDetailPage(item) {
				this.$emit('toDetailPage', item)
			},
			totalNumber(item) {
				let totalNumbers = 0;
				for (let ele of item) {
					totalNumbers += ele.goodsNumber;
				};
				return totalNumbers;
			},
			// --------api------获取数据
			getQueryList(isMerge) {
				let that = this;
				uni.showLoading({
					title: '加载中',
					mask: true
				});
				if (!isMerge) {
					this.cancellForm.current = 1;
					this.loadMoreStatus = 'more';
				};
				getQueryScheduledApi(this.cancellForm).then((res) => {
					let data = res.data;
					if (isMerge) {
						that.$util.SplitArray(data.records, that.dataList);
					} else {
						that.dataList = data.records;
					}
					that.totalPage = data.pages;
					if (data.pages == this.cancellForm.current || data.pages == 0) {
						that.loadMoreStatus = 'noMore';
					}
					uni.hideLoading();
				})
			},
		}
	}
</script>

<style>
	.pd_card {
		background-color: #fff;
		padding: 30rpx 20rpx;
		border-bottom: 2rpx solid #f5f5f5;
	}
</style>